<template>
  <div class="app-container">
    <template>
      <div class="hidden-md-and-up">
        <el-alert title="如若不适应手机端操作，建议使用电脑操作" type="warning" />
      </div>
    </template>
    <div class="table-container">
      <div style="padding-bottom:20px; display: flex;">
        <el-button type="primary" size="medium" plain @click="addthesis">我的鉴定录入</el-button>
        <div style="width: 200px; margin-left: 20px;">
          <el-input v-model="search" size="medium" placeholder="输入关键字搜索" />
        </div>
        <div style="margin-left: 20px;" />
        <el-button type="success" size="medium" plain icon="el-icon-download" @click="excel_dialog = true">导出</el-button>
      </div>
      <el-table
        v-loading="paperListLoading"
        :data="paperList"
        element-loading-text="Loading"
        border
        fit
      >
        <el-table-column type="selection" align="center" width="55" />
        <!-- <el-table-column align="center" label="序号" width="55">
          <template slot-scope="scope">
            {{ scope.$index+1 }}
          </template>
        </el-table-column> -->
        <el-table-column align="center" label="成果名称" min-width="120">
          <template slot-scope="scope">
            {{ scope.row.achievementName }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="所属机构" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.organization }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="鉴定部门" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.identifyDept }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="鉴定日期" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.identifyDate }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="鉴定结论" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.identifyResult }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="鉴定号" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.identifyNum }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="学校署名" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.schoolSigned }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="所有作者" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.allAuthor }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="审批结果" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.identifyResult }}
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          label="状态"
          :filters="[{ text: '草稿', value: '草稿' }, { text: '待院级审核', value: '待院级审核' }, { text: '被院级退回', value: '被院级退回' }, { text: '待校级审核', value: '待校级审核' }, { text: '被校级退回', value: '被校级退回' }, { text: '审核通过', value: '审核通过' }]"
          :filter-method="filterTag"
          filter-placement="bottom-end"
          min-width="120"
        >
          <template slot-scope="scope">
            <el-tag :type="scope.row.status | statusFilter">{{ scope.row.status }}</el-tag>
            <el-tag v-if="scope.row.status === '被院级退回' || scope.row.status === '被校级退回'" type="warning">{{ scope.row.reason }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="操作" width="230">
          <template slot-scope="scope">
            <el-popover
              :ref="`popoverdelete-${scope.$index}`"
              placement="top"
              width="160"
            >
              <p>确认删除本行吗？该操作不可撤销</p>
              <div style="text-align: right; margin: 0">
                <el-button size="mini" type="text" @click="scope._self.$refs[`popoverdelete-${scope.$index}`].doClose()">取消</el-button>
                <el-button type="primary" size="mini" @click="delete_thesis(scope.$index, scope.row)">确定</el-button>
              </div>
            </el-popover>
            <el-popover
              :ref="`popovercommit-${scope.$index}`"
              placement="top"
              width="160"
            >
              <p>确认提交吗？提交后不可再修改</p>
              <div style="text-align: right; margin: 0">
                <el-button size="mini" type="text" @click="scope._self.$refs[`popovercommit-${scope.$index}`].doClose()">取消</el-button>
                <el-button type="primary" size="mini" @click="commit_thesis(scope.$index, scope.row)">确定</el-button>
              </div>
            </el-popover>
            <!-- <el-popover
              :ref="`popoveredit-${scope.$index}`"
              placement="top"
            >
              <div style="text-align: center; margin: 0">
                <el-button type="primary" size="mini" @click="open_thesis_info_dialog(scope.row)">专利信息</el-button>
                <el-button type="primary" size="mini" @click="open_thesis_author_dialog(scope.row)">作者列表</el-button>
                <el-button type="primary" size="mini" @click="open_thesis_project_dialog(scope.row)">相关项目</el-button>
                <el-button type="primary" size="mini">相关附件</el-button>
                <el-button type="primary" size="mini" @click="open_infoview_dialog(scope.row)">信息总览</el-button>
              </div>
            </el-popover> -->
            <el-button
              size="mini"
              @click="open_infoview_dialog(scope.row)"
            >
              编辑
            </el-button>
            <el-button
              v-popover="`popoverdelete-${scope.$index}`"
              size="mini"
              type="danger"
            >
              删除
            </el-button>
            <el-button
              v-popover="`popovercommit-${scope.$index}`"
              size="mini"
              type="success"
            >
              提交
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          background
          :current-page="p1_page"
          :page-sizes="[1,2,3,10, 20, 30, 40]"
          :page-size="p1_size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="p1_total"
          @size-change="p1_sizechange"
          @current-change="p1_currentchange"
        />
        <!-- @size-change="handleSizeChange"
          @current-change="handleCurrentChange" -->
        <!-- 使用了size-change和current-change事件来处理页码大小和当前页变动时候触发的事件。 -->
      </div>
      <el-dialog title="我的鉴定录入" :visible.sync="thesis_add_dialog" width="75%" :close-on-click-modal="false">
        <el-form ref="thesis_add_form1" :model="thesis_add_form1" :rules="add_rules" label-position="top" label-width="160px" autocomplete="off">
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="录入人" prop="entered">
                <el-input v-model="thesis_add_form1.entered" :disabled="true" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="统计分类" prop="classifi">
                <el-select v-model="thesis_add_form1.classifi" placeholder="请选择成果类型" style="width: 270px;">
                  <el-option label="社科类" value="社科类" />
                  <el-option label="科技类" value="科技类" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="所属机构" prop="organization">
                <el-input v-model="thesis_add_form1.organization" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="成果名称" prop="achievementName">
                <el-input v-model="thesis_add_form1.achievementName" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="鉴定部门" prop="identifyDept">
                <el-input v-model="thesis_add_form1.identifyDept" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="鉴定级别" prop="identifyLevel">
                <el-select v-model="thesis_add_form1.identifyLevel" placeholder="请选鉴定级别" style="width: 270px;">
                  <el-option label="国家级" value="社科类" />
                  <el-option label="省部级" value="科技类" />
                  <el-option label="市厅级" value="科技类" />
                  <el-option label="校级" value="科技类" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="鉴定结论" prop="identifyResult">
                <el-select v-model="thesis_add_form1.identifyResult" placeholder="请选鉴定结论" style="width: 270px;">
                  <el-option label="国际领先" value="国际领先" />
                  <el-option label="国际先进" value="国际先进" />
                  <el-option label="国内领先" value="国内领先" />
                  <el-option label="国内先进" value="国内先进" />
                  <el-option label="其它" value="其它" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="所有作者" prop="allAuthor">
                <el-input v-model="thesis_add_form1.allAuthor" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="鉴定日期" prop="identifyDate">
                <el-date-picker
                  v-model="thesis_add_form1.identifyDate"
                  type="date"
                  placeholder="选择日期"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="yyyy-MM-dd"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="院系" prop="dept">
                <el-input v-model="thesis_add_form1.dept" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="科技成果登记证书号" prop="certificateID">
                <el-input v-model="thesis_add_form1.certificateID" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="完成形式" prop="completionForm">
                <el-input v-model="thesis_add_form1.completionForm" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="通讯作者" prop="correspondingAuthor">
                <el-input v-model="thesis_add_form1.correspondingAuthor" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="学科门类" prop="discipline">
                <el-input v-model="thesis_add_form1.discipline" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="鉴定号" prop="identifyNum">
                <el-input v-model="thesis_add_form1.identifyNum" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="学校署名" prop="schoolSigned">
                <el-input v-model="thesis_add_form1.schoolSigned" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
            <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
              <br>
            </el-col>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="关联项目" prop="associatedProjects">
                <el-input v-model="thesis_add_form1.associatedProjects" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
              <el-form-item label="备注" prop="ninthAuthor">
                <el-input v-model="thesis_add_form1.notes" style="min-width: 270px;" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-popover
            ref="dialog1"
            v-model="visible1"
            placement="top"
            width="160"
          >
            <p>关闭后，已填写的内容会丢失，建议保存为草稿，确定要关闭吗？</p>
            <div style="text-align: right; margin: 0">
              <el-button size="mini" type="text" @click="visible1 = false">取消</el-button>
              <el-button type="primary" size="mini" @click="visible1 = false;thesis_add_dialog = false;">确定</el-button>
            </div>
          </el-popover>
          <el-button v-popover:dialog1>关 闭</el-button>
          <el-tooltip placement="top" effect="light">
            <div slot="content">检查表单是否填写正确<br>若不正确则最终无法提交审核</div>
            <el-button type="primary" plain @click="check_rules('thesis_add_form1')">检 查</el-button>
          </el-tooltip>
          <el-button type="primary" @click="save_add_form1(thesis_add_form1)">保 存</el-button>
        </div>
      </el-dialog>
      <el-dialog title="编辑信息" :visible.sync="infoview_dialog" width="75%">
        <el-collapse v-model="activeNames">
          <el-collapse-item name="1">
            <template slot="title">
              <div class="el-descriptions__title">成果鉴定信息</div>
            </template>
            <el-dialog title="成果鉴定信息" :visible.sync="thesis_info_dialog" width="60%" append-to-body :close-on-click-modal="false">
              <el-form ref="thesis_add_form2" :model="thesis_add_form2" :rules="add_rules" label-position="top" label-width="160px" autocomplete="off">
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="录入人" prop="entered">
                      <el-input v-model="thesis_add_form2.entered" :disabled="true" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="统计分类" prop="classifi">
                      <el-select v-model="thesis_add_form2.classifi" placeholder="请选择成果类型" style="width: 270px;">
                        <el-option label="社科类" value="社科类" />
                        <el-option label="科技类" value="科技类" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="所属机构" prop="organization">
                      <el-input v-model="thesis_add_form2.organization" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="成果名称" prop="achievementName">
                      <el-input v-model="thesis_add_form2.achievementName" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="鉴定部门" prop="identifyDept">
                      <el-input v-model="thesis_add_form2.identifyDept" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="鉴定级别" prop="identifyLevel">
                      <el-select v-model="thesis_add_form2.identifyLevel" placeholder="请选鉴定级别" style="width: 270px;">
                        <el-option label="国家级" value="社科类" />
                        <el-option label="省部级" value="科技类" />
                        <el-option label="市厅级" value="科技类" />
                        <el-option label="校级" value="科技类" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="鉴定结论" prop="identifyResult">
                      <el-select v-model="thesis_add_form2.identifyResult" placeholder="请选鉴定结论" style="width: 270px;">
                        <el-option label="国际领先" value="国际领先" />
                        <el-option label="国际先进" value="国际先进" />
                        <el-option label="国内领先" value="国内领先" />
                        <el-option label="国内先进" value="国内先进" />
                        <el-option label="其它" value="其它" />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="所有作者" prop="allAuthor">
                      <el-input v-model="thesis_add_form2.allAuthor" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="鉴定日期" prop="identifyDate">
                      <el-date-picker
                        v-model="thesis_add_form2.identifyDate"
                        type="date"
                        placeholder="选择日期"
                        format="yyyy 年 MM 月 dd 日"
                        value-format="yyyy-MM-dd"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="院系" prop="dept">
                      <el-input v-model="thesis_add_form2.dept" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="科技成果登记证书号" prop="certificateID">
                      <el-input v-model="thesis_add_form2.certificateID" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="完成形式" prop="completionForm">
                      <el-input v-model="thesis_add_form2.completionForm" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="通讯作者" prop="correspondingAuthor">
                      <el-input v-model="thesis_add_form2.correspondingAuthor" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="学科门类" prop="discipline">
                      <el-input v-model="thesis_add_form2.discipline" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="鉴定号" prop="identifyNum">
                      <el-input v-model="thesis_add_form2.identifyNum" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="学校署名" prop="schoolSigned">
                      <el-input v-model="thesis_add_form2.schoolSigned" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="1" :sm="1" :md="2" :lg="2" :xl="2">
                    <br>
                  </el-col>
                  <el-col :xs="20" :sm="20" :md="10" :lg="10" :xl="8">
                    <el-form-item label="备注" prop="notes">
                      <el-input v-model="thesis_add_form2.notes" style="min-width: 270px;" />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-popover
                  ref="dialog2"
                  v-model="visible2"
                  placement="top"
                  width="160"
                >
                  <p>关闭后，已填写的内容会丢失，建议保存为草稿，确定要关闭吗？</p>
                  <div style="text-align: right; margin: 0">
                    <el-button size="mini" type="text" @click="visible2 = false">取消</el-button>
                    <el-button type="primary" size="mini" @click="visible2 = false;thesis_info_dialog = false;">确定</el-button>
                  </div>
                </el-popover>
                <el-button v-popover:dialog2>关 闭</el-button>
                <el-tooltip placement="top" effect="light">
                  <div slot="content">检查表单是否填写正确<br>若不正确则最终无法提交审核</div>
                  <el-button type="primary" plain @click="check_rules('thesis_add_form2')">检 查</el-button>
                </el-tooltip>
                <el-button type="primary" @click="save_add_form2(thesis_add_form2)">保 存</el-button>
              </div>
            </el-dialog>
            <div style="padding-bottom:20px; display: flex;">
              <el-button type="primary" size="medium" plain @click="open_thesis_info_dialog(infoview1)">编辑信息</el-button>
            </div>
            <el-descriptions :column="2" size="medium" border :label-style="{width:'25%'}" :content-style="{width:'25%'}">
              <el-descriptions-item label="成果鉴定ID">
                {{ infoview1.identifyID }}
              </el-descriptions-item>
              <el-descriptions-item label="录入人">
                {{ infoview1.entered }}
              </el-descriptions-item>
              <el-descriptions-item label="统计分类">
                {{ infoview1.classifi }}
              </el-descriptions-item>
              <el-descriptions-item label="所属机构">
                {{ infoview1.organization }}
              </el-descriptions-item>
              <el-descriptions-item label="成果名称">
                {{ infoview1.achievementName }}
              </el-descriptions-item>
              <el-descriptions-item label="鉴定部门">
                {{ infoview1.identifyDept }}
              </el-descriptions-item>
              <el-descriptions-item label="鉴定级别">
                {{ infoview1.identifyLevel }}
              </el-descriptions-item>
              <el-descriptions-item label="鉴定结论">
                {{ infoview1.identifyResult }}
              </el-descriptions-item>
              <el-descriptions-item label="所有作者">
                {{ infoview1.allAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="录入日期">
                {{ infoview1.enteredDate }}
              </el-descriptions-item>
              <el-descriptions-item label="鉴定日期">
                {{ infoview1.identifyDate }}
              </el-descriptions-item>
              <el-descriptions-item label="院系">
                {{ infoview1.dept }}
              </el-descriptions-item>
              <el-descriptions-item label="科技成果登记证书号">
                {{ infoview1.certificateID }}
              </el-descriptions-item>
              <el-descriptions-item label="完成形式">
                {{ infoview1.completionForm }}
              </el-descriptions-item>
              <el-descriptions-item label="通讯作者">
                {{ infoview1.correspondingAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="学科门类">
                {{ infoview1.discipline }}
              </el-descriptions-item>
              <el-descriptions-item label="鉴定号">
                {{ infoview1.identifyNum }}
              </el-descriptions-item>
              <el-descriptions-item label="学校署名">
                {{ infoview1.schoolSigned }}
              </el-descriptions-item>
              <el-descriptions-item label="第一作者">
                {{ infoview1.leadAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="第二作者">
                {{ infoview1.secondAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="第三作者">
                {{ infoview1.thirdAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="第四作者">
                {{ infoview1.fourthAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="第五作者">
                {{ infoview1.fifthAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="第六作者">
                {{ infoview1.sixthAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="第七作者">
                {{ infoview1.seventhAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="第八作者">
                {{ infoview1.eighthAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="第九作者">
                {{ infoview1.ninthAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="审核状态">
                <el-tag :type="infoview1.status | statusFilter">{{ infoview1.status }}</el-tag>
              </el-descriptions-item>
              <el-descriptions-item label="未通过原因">
                {{ infoview1.reason }}
              </el-descriptions-item>
              <el-descriptions-item label="备注">
                {{ infoview1.notes }}
              </el-descriptions-item>
            </el-descriptions>
          </el-collapse-item>
          <el-collapse-item name="2">
            <template slot="title">
              <div class="el-descriptions__title">作者信息</div>
            </template>
            <el-dialog width="60%" :title="innerdialog1_title" :visible.sync="thesis_author_innerdialog" append-to-body :close-on-click-modal="false">
              <el-form ref="thesis_author_form" :model="thesis_author_form" label-position="top" label-width="160px">
                <el-form-item label="工号" prop="userAccount">
                  <el-input v-model="thesis_author_form.userAccount" />
                </el-form-item>
                <el-form-item label="姓名" prop="name">
                  <el-input v-model="thesis_author_form.name" />
                </el-form-item>
                <el-form-item label="所属院系" prop="dept">
                  <el-select v-model="thesis_author_form.dept" placeholder="请选择学院">
                    <el-option label="计算机与信息工程学院" value="计算机与信息工程学院" />
                    <el-option label="计算机与信息工程学院" value="计算机与信息工程学院" />
                  </el-select>
                </el-form-item>
                <el-form-item label="作者类型" prop="authorCate">
                  <el-select v-model="thesis_author_form.authorCate" placeholder="请选择">
                    <el-option label="作者类型" value="作者类型" />
                    <el-option label="作者类型" value="作者类型" />
                  </el-select>
                </el-form-item>
                <el-form-item label="排名" prop="ranking">
                  <el-select v-model="thesis_author_form.ranking" placeholder="请选择">
                    <el-option label="1" value="1" />
                    <el-option label="2" value="2" />
                  </el-select>
                </el-form-item>
                <el-form-item label="考核系数" prop="assessment">
                  <el-input v-model="thesis_author_form.assessment" />
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="thesis_author_innerdialog = false">取 消</el-button>
                <el-button v-if="innerdialog1_add" type="primary" @click="add_thesis_author">确 定</el-button>
                <el-button v-if="!innerdialog1_add" type="primary" @click="edit_thesis_author">确 定</el-button>
              </div>
            </el-dialog>
            <div style="padding-bottom:20px; display: flex;">
              <el-button type="primary" size="medium" plain @click="open_add_author_innerdialog">添加作者</el-button>
            </div>
            <el-table
              v-loading="paperAuthorListLoading"
              :data="paperAuthorList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column type="selection" align="center" width="55" />
              <el-table-column align="center" label="姓名" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.name }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="所属院系" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.dept }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="排名" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.ranking }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="作者类型" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.authorCate }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="考核系数" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.assessment }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="150">
                <template slot-scope="scope">
                  <el-popover
                    :ref="`popoverdelete-${scope.$index}`"
                    placement="top"
                    width="160"
                  >
                    <p>确认删除本行吗？该操作不可撤销</p>
                    <div style="text-align: right; margin: 0">
                      <el-button size="mini" type="text" @click="scope._self.$refs[`popoverdelete-${scope.$index}`].doClose()">取消</el-button>
                      <el-button type="primary" size="mini" @click="delete_thesis_author(scope.$index, scope.row)">确定</el-button>
                    </div>
                  </el-popover>
                  <el-button
                    size="mini"
                    @click="open_edit_author_innerdialog(scope.$index, scope.row)"
                  >
                    编辑
                  </el-button>
                  <el-button
                    v-popover="`popoverdelete-${scope.$index}`"
                    size="mini"
                    type="danger"
                  >
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
          <el-collapse-item name="3">
            <template slot="title">
              <div class="el-descriptions__title">相关项目</div>
            </template>
            <el-dialog width="60%" :title="innerdialog2_title" :visible.sync="thesis_project_innerdialog" append-to-body :close-on-click-modal="false">
              <el-form ref="thesis_project_form" :model="thesis_project_form" label-position="top" label-width="160px">
                <el-form-item label="项目名称" prop="projectName">
                  <el-input v-model="thesis_project_form.projectName" />
                </el-form-item>
                <el-form-item label="项目负责人" prop="head">
                  <el-input v-model="thesis_project_form.head" />
                </el-form-item>
                <el-form-item label="署名单位" prop="signedUnit">
                  <el-select v-model="thesis_project_form.signedUnit" placeholder="请选择">
                    <el-option label="署名单位" value="署名单位" />
                    <el-option label="署名单位" value="署名单位" />
                  </el-select>
                </el-form-item>
                <el-form-item label="开始日期" prop="startTime">
                  <el-date-picker
                    v-model="thesis_project_form.startTime"
                    type="date"
                    placeholder="选择日期"
                    format="yyyy 年 MM 月 dd 日"
                    value-format="yyyy-MM-dd"
                  />
                </el-form-item>
                <el-form-item label="结束日期" prop="endTime">
                  <el-date-picker
                    v-model="thesis_project_form.endTime"
                    type="date"
                    placeholder="选择日期"
                    format="yyyy 年 MM 月 dd 日"
                    value-format="yyyy-MM-dd"
                  />
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="thesis_project_innerdialog = false">取 消</el-button>
                <el-button v-if="innerdialog2_add" type="primary" @click="add_thesis_project">确 定</el-button>
                <el-button v-if="!innerdialog2_add" type="primary" @click="edit_thesis_project">确 定</el-button>
              </div>
            </el-dialog>
            <div style="padding-bottom:20px; display: flex;">
              <el-button type="primary" size="medium" plain @click="open_add_project_innerdialog">添加相关项目</el-button>
            </div>
            <el-table
              v-loading="paperProjectListLoading"
              :data="paperProjectList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column type="selection" align="center" width="55" />
              <el-table-column align="center" label="项目名称" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.projectName }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="项目负责人" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.head }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="署名单位" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.signedUnit }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="开始日期" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.startTime }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="结束日期" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.endTime }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="150">
                <template slot-scope="scope">
                  <el-popover
                    :ref="`popoverdelete-${scope.$index}`"
                    placement="top"
                    width="160"
                  >
                    <p>确认删除本行吗？该操作不可撤销</p>
                    <div style="text-align: right; margin: 0">
                      <el-button size="mini" type="text" @click="scope._self.$refs[`popoverdelete-${scope.$index}`].doClose()">取消</el-button>
                      <el-button type="primary" size="mini" @click="delete_thesis_project(scope.$index, scope.row)">确定</el-button>
                    </div>
                  </el-popover>
                  <el-button
                    size="mini"
                    @click="open_edit_project_innerdialog(scope.$index, scope.row)"
                  >
                    编辑
                  </el-button>
                  <el-button
                    v-popover="`popoverdelete-${scope.$index}`"
                    size="mini"
                    type="danger"
                  >
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
          <el-collapse-item name="4">
            <template slot="title">
              <div class="el-descriptions__title">附件信息</div>
            </template>
            <div class="upload">
              <div class="uploadBox">
                <el-upload
                  ref="upload"
                  class="upload-demo"
                  drag
                  action="http://218.197.18.189:9528/fileUpload/fileUpload"
                  accept=".jpg,.png,.doc,.docx,.xls,.xlsx,.pdf"
                  :on-success="handleFileSuccess"
                  :show-file-list="true"
                >
                  <i class="el-icon-upload" />
                  <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png/doc/xls/pdf/docx/xlsx文件，且不超过50MB</div>
                </el-upload>
              </div>
              <div class="uploadText">
                <el-alert
                  title="注意事项"
                  type="warning"
                  :closable="false"
                  :show-icon="true"
                >
                  <p>1、一次上传一个文件，上传完成的文件会在下方表格中显示</p>
                  <p>2、在下方表格中您可以进行下载和删除操作</p>
                  <p>3、本模块您需要上传的附件有“XXXXX”、“XXXXXX”</p>
                  <p>4、高质量论文必须上传论文和检索报告等</p>
                </el-alert>
              </div>
            </div>
            <el-table
              v-loading="fileListLoading"
              :data="fileList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column type="index" align="center" width="55" />
              <el-table-column align="left" label="文件名称" min-width="150">
                <template slot-scope="scope">
                  {{ scope.row.filename }}
                </template>
              </el-table-column>
              <el-table-column align="left" label="文件大小" min-width="150">
                <template slot-scope="scope">
                  <span v-if="scope.row.filesize / 1024 / 1024 < 1">{{ (scope.row.filesize / 1024).toFixed(2) + 'KB' }}</span>
                  <span v-else>{{ (scope.row.filesize / 1024 / 1024).toFixed(2) + 'MB' }}</span>
                </template>
              </el-table-column>
              <el-table-column align="left" label="文件上传时间" min-width="150">
                <template slot-scope="scope">
                  {{ scope.row.filedate }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="150">
                <template slot-scope="scope">
                  <el-popover
                    :ref="`popoverdelete-${scope.$index}`"
                    placement="top"
                    width="160"
                  >
                    <p>确认删除本行吗？该操作不可撤销</p>
                    <div style="text-align: right; margin: 0">
                      <el-button size="mini" type="text" @click="scope._self.$refs[`popoverdelete-${scope.$index}`].doClose()">取消</el-button>
                      <el-button type="primary" size="mini" @click="deleteFile(scope.$index, scope.row)">确定</el-button>
                    </div>
                  </el-popover>
                  <el-button
                    size="mini"
                    @click="downloadFile(scope.row)"
                  >
                    下载
                  </el-button>
                  <el-button
                    v-popover="`popoverdelete-${scope.$index}`"
                    size="mini"
                    type="danger"
                  >
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
        </el-collapse>
        <div slot="footer" class="dialog-footer">
          <el-button @click="infoview_dialog = false">关 闭</el-button>
        </div>
      </el-dialog>
      <el-dialog title="导出excel" :visible.sync="excel_dialog" width="60%">
        <el-alert
          title="请选择需要导出的数据"
          type="success"
          description="选择的数据为表头，未选择的数据将不会导出"
          :closable="false"
        />
        <div style="margin: 15px;">
          <el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">全选</el-checkbox>
          <div style="margin: 15px 0;" />
          <el-checkbox-group v-model="check_fields" @change="handleCheckedFieldsChange">
            <el-checkbox v-for="field in fields_list" :key="field" :label="field">{{ field }}</el-checkbox>
          </el-checkbox-group>
        </div>
        <el-alert
          title="请选择时间范围"
          type="success"
          description="选择导出数据的时间范围"
          :closable="false"
        />
        <div slot="footer" class="dialog-footer">
          <el-button @click="excel_dialog = false">关 闭</el-button>
          <download-excel
            style="display:inline-block !important;margin-left:10px;"
            :data="EXCEL.DetailsForm"
            :fields="EXCEL.json_fields"
            :header="EXCEL.title"
            type="xls"
            name="专利数据导出.xls"
            :fetch="createExportData"
            :before-generate="startDownload"
            :before-finish="finishDownload"
          >
            <!-- 上面可以自定义自己的样式，还可以引用其他组件button -->
            <el-button type="success" plain>确认导出</el-button>
          </download-excel>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import { getMyPaperList, thesis_add, thesis_add2, thesis_delete, thesis_commit, get_thesis_author, thesis_author_add, thesis_author_delete, thesis_author_edit, get_thesis_project, thesis_project_add, thesis_project_delete, thesis_project_edit, file_add, get_file, file_delete } from '@/api/identify'
import { Message, Loading } from 'element-ui'
import { mapGetters } from 'vuex'

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        草稿: 'info',
        待院级审核: '',
        被院级退回: 'danger',
        待校级审核: '',
        被校级退回: 'danger',
        审核通过: 'success'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      search: '',
      thesis_add_dialog: false,
      thesis_info_dialog: false,
      // thesis_author_dialog: false,
      // thesis_project_dialog: false,
      thesis_author_innerdialog: false,
      thesis_project_innerdialog: false,
      infoview_dialog: false,
      visible1: false,
      visible2: false,
      thesis_add_form1: {
        achievementName: '',
        allAuthor: '',
        annex: '',
        associatedProjects: '',
        certificateID: '',
        classifi: '',
        completionForm: '',
        correspondingAuthor: '',
        dept: '',
        discipline: '',
        eighthAuthor: '',
        entered: '',
        enteredDate: '',
        fifthAuthor: '',
        fourthAuthor: '',
        identifyDate: '',
        identifyDept: '',
        identifyID: '',
        identifyLevel: '',
        identifyNum: '',
        identifyResult: '',
        leadAuthor: '',
        ninthAuthor: '',
        notes: '',
        organization: '',
        reason: '',
        schoolSigned: '',
        secondAuthor: '',
        seventhAuthor: '',
        sixthAuthor: '',
        status: '',
        thirdAuthor: ''
      },
      thesis_add_form2: {
        achievementName: '',
        allAuthor: '',
        annex: '',
        associatedProjects: '',
        certificateID: '',
        classifi: '',
        completionForm: '',
        correspondingAuthor: '',
        dept: '',
        discipline: '',
        eighthAuthor: '',
        entered: '',
        enteredDate: '',
        fifthAuthor: '',
        fourthAuthor: '',
        identifyDate: '',
        identifyDept: '',
        identifyID: '',
        identifyLevel: '',
        identifyNum: '',
        identifyResult: '',
        leadAuthor: '',
        ninthAuthor: '',
        notes: '',
        organization: '',
        reason: '',
        schoolSigned: '',
        secondAuthor: '',
        seventhAuthor: '',
        sixthAuthor: '',
        status: '',
        thirdAuthor: ''
      },
      add_rules: {
        entered: [],
        classifi: [
          { required: true, message: '统计分类不能为空', trigger: 'blur' }
        ],
        organization: [
          { required: true, message: '组织单位不能为空', trigger: 'blur' }
        ],
        achievementName: [
          { required: true, message: '成果名称不能为空', trigger: 'blur' }
        ],
        identifyDept: [
          { required: true, message: '鉴定部门不能为空', trigger: 'blur' }
        ],
        identifyLevel: [
          { required: true, message: '鉴定等级不能为空', trigger: 'blur' }
        ],
        identifyResult: [
          { required: true, message: '鉴定结果不能为空', trigger: 'blur' }
        ],
        allAuthor: [],
        identifyDate: [
          { required: true, message: '鉴定日期不能为空', trigger: 'blur' }
        ],
        dept: [],
        certificateID: [],
        completionForm: [
          { required: true, message: '完成形式不能为空', trigger: 'blur' }
        ],
        correspondingAuthor: [],
        discipline: [
          { required: true, message: '学科不能为空', trigger: 'blur' }
        ],
        identifyNum: [],
        schoolSigned: [],
        associatedProjects: [],
        notes: []
      },
      thesis_author_form: {
        assessment: '',
        authorCate: '',
        authorType: '',
        dept: '',
        identifyAuthorID: '',
        identifyID: '',
        name: '',
        ranking: '',
        userAccount: ''
      },
      thesis_project_form: {
        campusID: '',
        endTime: '',
        head: '',
        identifyID: '',
        identifyProjectID: '',
        projectID: '',
        projectName: '',
        startTime: ''
      },
      paperList: null,
      paperListLoading: false,
      p1_size: 10,
      p1_total: 0,
      p1_page: 1,
      paperAuthorList: null,
      paperAuthorListLoading: false,
      innerdialog1_title: '新增作者',
      innerdialog1_add: true,
      paperProjectList: null,
      paperProjectListLoading: false,
      innerdialog2_title: '新增作者',
      innerdialog2_add: true,
      infoview1: {
        achievementName: '',
        allAuthor: '',
        annex: '',
        associatedProjects: '',
        certificateID: '',
        classifi: '',
        completionForm: '',
        correspondingAuthor: '',
        dept: '',
        discipline: '',
        eighthAuthor: '',
        entered: '',
        enteredDate: '',
        fifthAuthor: '',
        fourthAuthor: '',
        identifyDate: '',
        identifyDept: '',
        identifyID: '',
        identifyLevel: '',
        identifyNum: '',
        identifyResult: '',
        leadAuthor: '',
        ninthAuthor: '',
        notes: '',
        organization: '',
        reason: '',
        schoolSigned: '',
        secondAuthor: '',
        seventhAuthor: '',
        sixthAuthor: '',
        status: '',
        thirdAuthor: ''
      },
      activeNames: ['1', '2', '3', '4'],
      excel_dialog: false,
      all_fields: {
        '成果名称': 'achievementName',
        '所有作者': 'allAuthor',
        '关联项目': 'associatedProjects',
        '科技成果登记证书号': 'certificateID',
        '统计分类': 'classifi',
        '完成形式': 'completionForm',
        '通讯作者': 'correspondingAuthor',
        '院系': 'dept',
        '学科门类': 'discipline',
        '第八作者': 'eighthAuthor',
        '录入人': 'entered',
        '录入日期': 'enteredDate',
        '第五作者': 'fifthAuthor',
        '第四作者': 'fourthAuthor',
        '鉴定日期': 'identifyDate',
        '鉴定部门': 'identifyDept',
        '成果鉴定ID': 'identifyID',
        '鉴定级别': 'identifyLevel',
        '鉴定号': 'identifyNum',
        '鉴定结论': 'identifyResult',
        '第一作者': 'leadAuthor',
        '第九作者': 'ninthAuthor',
        '备注': 'notes',
        '所属机构': 'organization',
        '未通过原因': 'reason',
        '学校署名': 'schoolSigned',
        '第二作者': 'secondAuthor',
        '第七作者': 'seventhAuthor',
        '第六作者': 'sixthAuthor',
        '审核阶段': 'status',
        '第三作者': 'thirdAuthor'
      },
      fields_list: [
        '成果名称',
        '所有作者',
        '关联项目',
        '科技成果',
        '统计分类',
        '完成形式',
        '通讯作者',
        '院系',
        '学科门类',
        '第八作者',
        '录入人',
        '录入日期',
        '第五作者',
        '第四作者',
        '鉴定日期',
        '鉴定部门',
        '成果鉴定',
        '鉴定级别',
        '鉴定号',
        '鉴定结论',
        '第一作者',
        '第九作者',
        '备注',
        '所属机构',
        '未通过原因',
        '学校署名',
        '第二作者',
        '第七作者',
        '第六作者',
        '审核阶段',
        '第三作者'
      ],
      check_fields: [],
      checkAll: false,
      isIndeterminate: false,
      EXCEL: {
        title: '测试表格',
        json_fields: null,
        DetailsForm: null
      },
      fileList: [],
      fileListLoading: false,
      fileForm: {
        identifyid: '',
        filedate: '',
        fileid: '',
        filename: '',
        filesize: '',
        fileurl: ''
      }
    }
  },
  computed: {
    ...mapGetters([
      'uid',
      'roles',
      'name'
    ]),
    MyPaperPost() {
      return {
        name: this.name,
        pageNum: this.p1_page,
        pageSize: this.p1_size
      }
    }
  },
  created() {
    this.fetchPaperData()
  },
  methods: {
    fetchPaperData() {
      this.paperListLoading = true
      getMyPaperList(this.MyPaperPost).then(response => {
        if (response.code === 200) {
          this.paperList = response.data.list
          this.p1_total = response.data.total
          this.paperListLoading = false
        }
      })
    },
    p1_sizechange(newsize) {
      this.p1_size = newsize
      this.p1_page = 1
      this.fetchPaperData()
    },
    p1_currentchange(newpage) {
      this.p1_page = newpage
      this.fetchPaperData()
    },
    filterTag(value, row) {
      return row.status === value
    },
    resetForm(formName) {
      if (this.$refs[formName] !== undefined) {
        this.$refs[formName].resetFields()
      }
    },
    check_rules(formName) {
      // 只校验必填项
      const form = this.$refs[formName]
      if (!form) {
        Message.error('表单引用不存在')
        return
      }

      // 修复：获取并显示第一个错误信息
      form.validate((valid, invalidFields) => {
        if (valid) {
          Message.success('表单填写正确！')
        } else {
          // 获取第一个错误并显示
          for (const field in invalidFields) {
            if (invalidFields[field] && invalidFields[field].length > 0) {
              Message.error(invalidFields[field][0].message)
              return
            }
          }
          Message.error('表单数据有误，请检查')
        }
      })
    },
    addthesis() {
      this.thesis_add_dialog = true
      this.resetForm('thesis_add_form1')
      this.thesis_add_form1.entered = this.name
    },
    save_add_form1(formdata) {
      // 添加表单验证逻辑
      this.$refs.thesis_add_form1.validate((valid, invalidFields) => {
        if (valid) {
          thesis_add(formdata).then(response => {
            if (response.code === 200) {
              Message.success('保存成功')
              this.thesis_add_dialog = false
              this.fetchPaperData()
            }
          })
        } else {
          // 获取第一个错误并显示
          for (const field in invalidFields) {
            if (invalidFields[field] && invalidFields[field].length > 0) {
              Message.error(invalidFields[field][0].message)
              return false
            }
          }
          Message.error('表单数据有误，请检查')
          return false
        }
      })
    },
    open_thesis_info_dialog(data) {
      this.thesis_info_dialog = true
      this.resetForm('thesis_add_form2')
      this.thesis_add_form2 = JSON.parse(JSON.stringify(data))
    },
    save_add_form2(formdata) {
      // 添加表单验证逻辑
      this.$refs.thesis_add_form2.validate((valid, invalidFields) => {
        if (valid) {
          thesis_add2(formdata).then(response => {
            if (response.code === 200) {
              Message.success('保存成功')
              this.thesis_info_dialog = false
              this.fetchPaperData()
              this.infoview1 = formdata
            }
          })
        } else {
          // 获取第一个错误并显示
          for (const field in invalidFields) {
            if (invalidFields[field] && invalidFields[field].length > 0) {
              Message.error(invalidFields[field][0].message)
              return false
            }
          }
          Message.error('表单数据有误，请检查')
          return false
        }
      })
    },
    delete_thesis(index, row) {
      this.$refs[`popoverdelete-${index}`].doClose()
      thesis_delete(row.identifyID).then(response => {
        if (response.code === 200) {
          Message.success('删除成功')
          this.fetchPaperData()
        }
      })
    },
    commit_thesis(index, row) {
      this.$refs[`popovercommit-${index}`].doClose()
      // 提交前先重新加载附件列表，确保fileList包含最新的附件数据
      this.fileForm.identifyid = row.identifyID
      this.fetchFileData().then(() => {
        // 等待附件列表加载完成后再检查
        if (this.fileList.length === 0) {
          this.$message.error('请上传附件')
          return
        }
        thesis_commit(row.identifyID).then(response => {
          if (response.code === 200) {
            Message.success('提交成功')
            this.fetchPaperData()
          }
        })
      })
    },
    fetch_thesis_author() {
      this.paperAuthorListLoading = true
      get_thesis_author(this.thesis_author_form.identifyID).then(response => {
        if (response.code === 200) {
          this.paperAuthorList = response.data
          this.paperAuthorListLoading = false
          console.log(response.data)
        }
      })
    },
    open_thesis_author_dialog(row) {
      this.thesis_author_dialog = true
      this.thesis_author_form.identifyID = row.identifyID
      this.fetch_thesis_author()
    },
    open_thesis_author_innerdialog() {
      this.thesis_author_innerdialog = true
      this.resetForm('thesis_author_form')
    },
    open_add_author_innerdialog() {
      this.open_thesis_author_innerdialog()
      this.innerdialog1_title = '新增作者'
      this.innerdialog1_add = true
    },
    open_edit_author_innerdialog(index, row) {
      this.open_thesis_author_innerdialog()
      this.innerdialog1_title = '编辑作者'
      this.thesis_author_form = JSON.parse(JSON.stringify(row))
      this.innerdialog1_add = false
    },
    add_thesis_author() {
      // 将作者类型从peopleType复制到authortype，确保表格正确显示作者类型
      this.thesis_author_form.authortype = this.thesis_author_form.peopleType
      thesis_author_add(this.thesis_author_form).then(response => {
        if (response.code === 200) {
          Message.success('保存成功')
          this.thesis_author_innerdialog = false
          this.fetch_thesis_author()
        }
      })
    },
    edit_thesis_author() {
      // 将作者类型从peopleType复制到authortype，确保表格正确显示作者类型
      this.thesis_author_form.authortype = this.thesis_author_form.peopleType
      thesis_author_edit(this.thesis_author_form).then(response => {
        if (response.code === 200) {
          Message.success('保存成功')
          this.thesis_author_innerdialog = false
          this.fetch_thesis_author()
        }
      })
    },
    delete_thesis_author(index, row) {
      this.$refs[`popoverdelete-${index}`].doClose()
      thesis_author_delete(row.identifyAuthorID).then(response => {
        if (response.code === 200) {
          Message.success('删除成功')
          this.fetch_thesis_author()
        }
      })
    },
    fetch_thesis_project() {
      this.paperProjectListLoading = true
      get_thesis_project(this.thesis_project_form.identifyID).then(response => {
        if (response.code === 200) {
          this.paperProjectList = response.data
          this.paperProjectListLoading = false
          console.log(response.data)
        }
      })
    },
    open_thesis_project_dialog(row) {
      this.thesis_project_dialog = true
      this.thesis_project_form.identifyID = row.identifyID
      this.fetch_thesis_project()
    },
    open_thesis_project_innerdialog() {
      this.thesis_project_innerdialog = true
      this.resetForm('thesis_project_form')
    },
    open_add_project_innerdialog() {
      this.open_thesis_project_innerdialog()
      this.innerdialog2_title = '新增相关项目'
      this.innerdialog2_add = true
    },
    open_edit_project_innerdialog(index, row) {
      this.open_thesis_project_innerdialog()
      this.innerdialog2_title = '编辑相关项目'
      this.thesis_project_form = JSON.parse(JSON.stringify(row))
      this.innerdialog2_add = false
    },
    add_thesis_project() {
      console.log(this.thesis_project_form)
      thesis_project_add(this.thesis_project_form).then(response => {
        if (response.code === 200) {
          Message.success('保存成功')
          this.thesis_project_innerdialog = false
          this.fetch_thesis_project()
        }
      })
    },
    edit_thesis_project() {
      thesis_project_edit(this.thesis_project_form).then(response => {
        if (response.code === 200) {
          Message.success('保存成功')
          this.thesis_project_innerdialog = false
          this.fetch_thesis_project()
        }
      })
    },
    delete_thesis_project(index, row) {
      this.$refs[`popoverdelete-${index}`].doClose()
      thesis_project_delete(row.identifyProjectID).then(response => {
        if (response.code === 200) {
          Message.success('删除成功')
          this.fetch_thesis_project()
        }
      })
    },
    open_infoview_dialog(row) {
      this.infoview_dialog = true
      this.infoview1 = JSON.parse(JSON.stringify(row))
      this.thesis_author_form.identifyID = row.identifyID
      this.fetch_thesis_author()
      this.thesis_project_form.identifyID = row.identifyID
      this.fetch_thesis_project()
      this.fileForm.identifyid = row.identifyID
      this.fetchFileData()
    },
    // 以下为数据导出
    handleCheckAllChange(val) {
      this.check_fields = val ? this.fields_list : []
      this.isIndeterminate = false
      this.EXCEL.json_fields = JSON.parse(JSON.stringify(this.all_fields, this.check_fields))
    },
    handleCheckedFieldsChange(value) {
      const checkedCount = value.length
      this.checkAll = checkedCount === this.fields_list.length
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.fields_list.length
      this.EXCEL.json_fields = JSON.parse(JSON.stringify(this.all_fields, this.check_fields))
    },
    async createExportData() {
      return await getMyPaperList(this.MyPaperPost).then(response => {
        if (response.code === 200) {
          if (response.data.list.length === 0) {
            Message.warning('返回数据为空，导出失败！')
            this.loadingInstance.close()
          }
          return response.data.list
        }
      })
    },
    startDownload() {
      this.excel_dialog = false
      this.loadingInstance = Loading.service({ text: '正在导出...' })
    },
    finishDownload() {
      setTimeout(() => {
        this.loadingInstance.close()
      }, 1000)
    },
    // 以下是附件上传
    handleFileSuccess(res, file, fileList) {
      this.fileForm.filename = file.name
      this.fileForm.filesize = file.size
      this.fileForm.fileurl = res.data
      this.commit_file()
    },
    commit_file() {
      file_add(this.fileForm).then(response => {
        if (response.code === 200) {
          Message.success('上传成功')
          this.fetchFileData()
        }
      })
    },
    fetchFileData() {
      this.fileListLoading = true
      return get_file(this.fileForm.identifyid).then(response => {
        if (response.code === 200) {
          this.fileList = response.data
          this.fileListLoading = false
        }
        return response
      })
    },
    downloadFile(row) {
      var a = document.createElement('a')
      var event = new MouseEvent('click')
      a.href = row.fileurl
      a.target = '_blank'
      a.dispatchEvent(event)
    },
    deleteFile(index, row) {
      this.$refs[`popoverdelete-${index}`].doClose()
      file_delete(row.fileid).then(response => {
        if (response.code === 200) {
          Message.success('删除成功')
          this.fetchFileData()
        }
      })
    }
  }
}
</script>

<style lang="scss">
.el-form{
  margin-left: 40px;
  .el-input,.el-select{
    width: 300px;
  }
}
.el-tag + .el-tag {
  margin: 10px 10px;
}
.margin-top {
  margin-top: 50px;
}
@media screen and (max-width:600px) {
  .el-dialog{
    width: 100% !important;
  }
  .el-form{
    margin-left: 25px;
  }
}
</style>
